home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / cproto-3.0 / cproto.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  5.0 KB  |  148 lines

  1. /* $Id: cproto.h 3.7 1993/05/26 01:36:04 cthuang Exp $
  2.  *
  3.  * Declarations for C function prototype generator
  4.  */
  5. #include "config.h"
  6.  
  7. /* Boolean type */
  8. typedef char boolean;
  9. #define FALSE    0
  10. #define TRUE    1
  11.  
  12. /* Source file text */
  13. typedef struct text {
  14.     char text[MAX_TEXT_SIZE];    /* source text */
  15.     long begin;         /* offset in temporary file */
  16. } Text;
  17.  
  18. /* This is a list of function parameters. */
  19. typedef struct parameter_list {
  20.     struct parameter *first;    /* pointer to first parameter in list */
  21.     struct parameter *last;    /* pointer to last parameter in list */  
  22.     long begin_comment;     /* begin offset of comment */
  23.     long end_comment;        /* end offset of comment */
  24.     char *comment;        /* comment at start of parameter list */
  25. } ParameterList;
  26.  
  27. /* Declaration specifier flags */
  28. #define DS_NONE     0    /* default */
  29. #define DS_EXTERN    1    /* contains "extern" specifier */
  30. #define DS_STATIC    2    /* contains "static" specifier */
  31. #define DS_CHAR     4    /* contains "char" type specifier */
  32. #define DS_SHORT    8    /* contains "short" type specifier */
  33. #define DS_FLOAT    16    /* contains "float" type specifier */
  34. #define DS_JUNK     32    /* we're not interested in this declaration */
  35.  
  36. /* This structure stores information about a declaration specifier. */
  37. typedef struct decl_spec {
  38.     unsigned short flags;    /* flags defined above */
  39.     char *text;         /* source text */
  40.     long begin;         /* offset in temporary file */
  41. } DeclSpec;
  42.  
  43. /* Styles of function definitions */
  44. #define FUNC_NONE        0    /* not a function definition */
  45. #define FUNC_TRADITIONAL    1    /* traditional style */
  46. #define FUNC_ANSI        2    /* ANSI style */
  47. #define FUNC_BOTH        3    /* both styles */
  48. typedef int FuncDefStyle;
  49.  
  50. /* This structure stores information about a declarator. */
  51. typedef struct declarator {
  52.     char *name;             /* name of variable or function */
  53.     char *text;             /* source text */
  54.     long begin;             /* offset in temporary file */
  55.     long begin_comment;         /* begin offset of comment */
  56.     long end_comment;            /* end offset of comment */
  57.     FuncDefStyle func_def;        /* style of function definition */
  58.     ParameterList params;        /* function parameters */
  59.     boolean pointer;            /* TRUE if it declares a pointer */
  60.     struct declarator *head;        /* head function declarator */
  61.     struct declarator *func_stack;    /* stack of function declarators */
  62.     struct declarator *next;        /* next declarator in list */
  63. } Declarator;
  64.  
  65. /* This is a list of declarators. */
  66. typedef struct declarator_list {
  67.     Declarator *first;        /* pointer to first declarator in list */
  68.     Declarator *last;        /* pointer to last declarator in list */  
  69. } DeclaratorList;
  70.  
  71. /* This structure stores information about a function parameter. */
  72. typedef struct parameter {
  73.     struct parameter *next;    /* next parameter in list */
  74.     DeclSpec decl_spec;
  75.     Declarator *declarator;
  76.     char *comment;        /* comment following the parameter */
  77. } Parameter;
  78.  
  79. /* parser stack entry type */
  80. typedef union {
  81.     Text text;
  82.     DeclSpec decl_spec;
  83.     Parameter *parameter;
  84.     ParameterList param_list;
  85.     Declarator *declarator;
  86.     DeclaratorList decl_list;
  87. } YYSTYPE;
  88.  
  89. /* Prototype styles */
  90. #define PROTO_NONE        0    /* do not output any prototypes */
  91. #define PROTO_TRADITIONAL    1    /* comment out parameters */
  92. #define PROTO_ABSTRACT        2    /* comment out parameter names */
  93. #define PROTO_ANSI        3    /* ANSI C prototype */
  94. typedef int PrototypeStyle;
  95.  
  96. /* The role of a function declarator */
  97. #define FUNC_OTHER    0    /* miscellaneous declaration */
  98. #define FUNC_PROTO    1    /* prototype */
  99. #define FUNC_DEF    2    /* function definition */
  100. typedef int FuncDeclRole;
  101.  
  102. /* Prototype/function definition output formats */
  103. #define FMT_OTHER        0    /* miscellaneous */
  104. #define FMT_PROTO        1    /* prototype */
  105. #define FMT_FUNC        2    /* function definition */
  106. #define FMT_FUNC_COMMENT    3    /* func. def. with parameter comments */
  107. typedef int FuncFormatType;
  108.  
  109. /* Prototype/function definition output format */
  110. typedef struct func_format {
  111.     char *decl_spec_prefix;    /* output before declaration specifier */
  112.     char *declarator_prefix;    /* output before declarator name */
  113.     char *declarator_suffix;    /* output before '(' of parameter list */
  114.     char *first_param_prefix;    /* output before first parameter */
  115.     char *middle_param_prefix;    /* output before each subsequent parameter */
  116.     char *last_param_suffix;    /* output after last parameter */
  117. } FuncFormat;
  118.  
  119. /* Program options */
  120. extern boolean extern_out;
  121. extern boolean static_out;
  122. extern boolean variables_out;
  123. extern boolean promote_param;
  124. extern PrototypeStyle proto_style;
  125. extern FuncDefStyle func_style;
  126. extern boolean proto_macro;
  127. extern boolean define_macro;
  128. extern char *macro_name;
  129. extern boolean proto_comments;
  130. extern boolean file_comments;
  131. extern boolean quiet;
  132. extern char *func_directive;
  133. extern int num_inc_dir;
  134. extern char *inc_dir[];
  135. extern FuncFormat fmt[4];
  136.  
  137. /* Global declarations */
  138. extern char progname[];
  139.  
  140. extern char *xmalloc(), *xstrdup(), *trim_path_sep();
  141. extern void put_error();
  142. extern void init_parser(), process_file(), pop_file();
  143. extern char *cur_file_name(), *cur_text();
  144. extern unsigned cur_line_num();
  145. extern FILE *cur_tmp_file();
  146. extern void cur_file_changed();
  147. extern long cur_begin_comment();
  148.